-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sorting by name or count in categories block #66453
base: trunk
Are you sure you want to change the base?
Add sorting by name or count in categories block #66453
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
}, | ||
"order": { | ||
"type": "string", | ||
"default": "asc" | ||
}, | ||
"orderBy": { | ||
"type": "string", | ||
"default": "name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the default query to prevent unexpected results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also wondering if we should create a query
attribute like the query loop has and include properties there like taxonomy
. But I am not sure how it would work with backward compatibility.
{ | ||
/* translators: label for ordering taxonomies by number of posts in descending order */ | ||
label: __( 'Highest #' ), | ||
value: 'count/desc', | ||
}, | ||
{ | ||
/* translators: label for ordering taxonomies by number of posts in ascending order */ | ||
label: __( 'Lowest #' ), | ||
value: 'count/asc', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure how to label these options.
Size Change: +261 B (+0.01%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
Flaky tests detected in bcc3a09. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11589735416
|
What?
Add a new setting to the Categories block to be able to order the list of taxonomies based on the name or the posts count. It is similar to what the query loop is doing.
Why?
They are supported queries and it provides more flexibility to the user.
How?
Include
order
andorderBy
in the block attributes and use their value in the query to retrieve the categories.Additionally, I added a Select control with the different options.
Testing Instructions